"""
__author__ = '霍格沃兹测试开发学社'
__desc__ = '更多测试开发技术探讨，请访问：https://ceshiren.com/t/topic/15860'
"""
import requests

"""
封装底层接口操作
"""


class BaseApi:

    def __init__(self):
        self.base_url = "http://litemall.hogwarts.ceshiren.com/"
        self.token = self.get_token()

    def do_request(self, data: dict):
        return requests.request(**data)

    def get_token(self):
        info = {
            "url": f"{self.base_url}/admin/auth/login",
            "method": "post",
            "json": {"username": "admin123", "password": "admin123"}
        }
        r = self.do_request(info)
        return r.json().get("data").get("token")
